package com.qf.bbapi.controller;

import com.qf.bbapi.config.SystemConfig;
import com.qf.bbapi.dto.TaskDto;
import com.qf.bbapi.service.intf.IntegralService;
import com.qf.bbapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * .::::.
 * .::::::::.
 * :::::::::::
 * ..:::::::::::'
 * '::::::::::::'
 * .::::::::::
 * '::::::::::::::..
 * ..::::::::::::.
 * ``::::::::::::::::
 * ::::``:::::::::'        .:::.
 * ::::'   ':::::'       .::::::::.
 * .::::'      ::::     .:::::::'::::.
 * .:::'       :::::  .:::::::::' ':::::.
 * .::'        :::::.:::::::::'      ':::::.
 * .::'         ::::::::::::::'         ``::::.
 * ...:::           ::::::::::::'              ``::.
 * ````':.          ':::::::::'                  ::::..
 * '.:::::'                    ':'````..
 *
 * @author 贾
 * @version 1.0
 * @description: TODO
 * @date 2022/7/2 20:50
 */
@RestController
@RequestMapping("/api/task/")
@Api(tags="任务接口")
@CrossOrigin
public class TaskController {
    @Resource
    private IntegralService service;
    @ApiOperation("签到")
    @GetMapping("signIn.do")
    public R signIn( TaskDto integral, HttpServletRequest request){
       return service.signIn(integral,request.getIntHeader("token"));
    }

    @GetMapping("shop.do")
    @ApiOperation("购买商品")
    public R shop(TaskDto integral,HttpServletRequest request){
        return service.shop(integral,request.getIntHeader("token"));
    }



    @GetMapping("select.do")
    @ApiOperation("查询积分")
    public R select(HttpServletRequest request){
        return service.select(request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }

    @GetMapping("selectSingIn.do")
    @ApiOperation("查询今日是否签到")
    public R selectSingIn( TaskDto integral,HttpServletRequest request){
        return service.selectSingIn(integral,request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }

}
